import logging.config
from functools import wraps

logger = logging.getLogger()


def case_logger(casename):
    """
    负责记录测试用例执行日志的装饰器。
    :param casename: 用例标题
    """

    def wrapper(func):
        @wraps(func)
        def inner(*args, **kwargs):
            logger.info(f"开始执行用例 => {casename}")
            try:
                f = func(*args, **kwargs)
            except AssertionError as e:
                logger.info(f"{casename} => 执行失败！")
                raise e
            else:
                logger.info(f"{casename} => 执行通过！")
                return f

        return inner

    return wrapper
